﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/common/header.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript" src="../../js/deptSingleSelect.js"></script>
<script type="text/javascript" src="../../js/roleSingleSelect.js"></script>
<a href="" title="权限管理——用户管理"></a>
<script type="text/javascript">

Ext.onReady(function(){
    Ext.BLANK_IMAGE_URL = ' ../../js/ext/images/default/s.gif'; 
    // ---------------------- Global vars and functions------------------------------
    Ext.SERVER = '<c:url value="/"/>';
  
  Ext.QuickTips.init();
    Ext.override(Ext.form.Field, 
    {   afterRender : Ext.form.Field.prototype.afterRender.createSequence(function()
        {
            var qt = this.qtip;
            if (qt)
            {   Ext.QuickTips.register({
                target:  this,
                title: '',
                css : 'background:#ff0000;',
                text: qt,
                enabled: true,
                showDelay: 20
                });
            }
        })
    });
    
    // --------------- form and window --------------------
     label1= new  Ext.form.Label({
							html:'<font size="2px">短信使用说明：<br>  '
								+'&nbsp;&nbsp;&nbsp;&nbsp;1、多个号码时需用","分割开;<br>'
								+'&nbsp;&nbsp;&nbsp;&nbsp;2、此短信平台每60个字符将计作一条短信，短信末尾将签上您的姓名;<br>'
								+'&nbsp;&nbsp;&nbsp;&nbsp;3、此短信平台暂时未开通联通方面服务。</font>'
						})
     img1=function(){
	document.getElementById('image').src+="?";
	document.getElementById('captcha_response').value="";
  };
    var imagePreview=new Ext.Panel({
    id: 'imagePreview',
    name: 'imageUrl',
   	fieldLabel: '验证码',
   	layout:'form',
    autoWidth: true, //自动调整图片宽度  
    height: 30, //图片高度  
    qtip: '看不清楚，换一张！',
    html:"<a href='#'  onclick='img1()'>看不清,换一张</a>",
    items:[
    {
	  	xtype:'box',
	  	id:'image',
	  	name:'image',
	  	autoEl: {  
	        tag: 'img',    //指定为img标签  
	        src: 'captcha.do'    //指定url路径  
	    }
    }
    ]
    });
    var detailForm = new Ext.form.FormPanel({
        bodyStyle: 'padding:5px',
        html:'<a href="<%=basePath%>help/srhm.jsp" target="_blank">帮助</a>',
        frame: true,
        layout: 'form',
        labelWidth : 80, 
        items: [{
             layout: 'form',
             frame:true,
             items: [
             		{			           
			            xtype:'label',
			            text: 'lengths:',
				   		id:'msg-lengths'
			        },
			        new  Ext.form.TextArea({    //TextArea
                          fieldLabel:'发送到*',
                          name:'userMobiles',
                          qtip: '填写手机号码，如有多个请用”,“隔开！',
                          height:90,
                          width: 880,
                          maxLength:600,
                          id: 'userMobiles',
                          allowBlank: false,
                          enableKeyEvents:true                        
                      }),
             		new  Ext.form.TextArea({    //TextArea
                          fieldLabel:'短信正文*',
                          name:'userNotes',
                          qtip: '填写短信正文，注意：正文如果超过60个字，将作为两条短信发送！',
                          height:90,
                          width: 880,
                          maxLength:600,
                          id: 'userNotes',
                          enableKeyEvents:true,
                          listeners :{
							render: function( self ){
								var l = Ext.get('msg-lengths');
								l.dom.innerHTML = '最大输入字数:'+self.maxLength+
									' 已输入:'+self.getValue().length+
									' 还余:' + (self.maxLength-self.getValue().length);
								
							},
							keyup:function(self, e){		
								var l = Ext.get('msg-lengths');
								l.dom.innerHTML = '最大输入字数:'+self.maxLength+
									' 已输入:'+self.getValue().length+
									' 还余:' + (self.maxLength-self.getValue().length);
							}
						    }
                      }),{
                         name: 'userRealName',
                         fieldLabel: '签名',
                         readOnly: true,
                         xtype: 'textfield',
                         qtip: '将作为短信签名发送！',
                         width: 180,
                         msgTarget: 'side'
                     },
                     imagePreview
					/*  {  
                           
						   autoEl: {  
						        tag: 'img',    //指定为img标签  
						        src: 'captcha.do'    //指定url路径  
						    }
						    
						    handler:function(){
						    alert('dddddd')
						    }
						}*/,{
                         name: 'captcha_response',
                         id:'captcha_response',
                         fieldLabel: '请输入验证码',
                         xtype: 'textfield',
                         width: 180,
                         msgTarget: 'side'
                     },
                     label1
					 ]
        }],
        buttons: [
            {
                text: '发送',
                handler: function(){
                  
                    if(detailForm.getForm().isValid()){
                        detailForm.getForm().submit({
                            url: '<c:url value="/sms/smsSend.do" />',
                            waitTitle: '请等待',                            
                            waitMsg: '正在发送短信中...',
                            timeout: 30,
                            success: function(response, action){
                            	text = action.response.responseText;
                                    json = Ext.decode(text);
									Ext.Msg.alert(text);
				                    if(json.success == true){  
                                        Ext.Msg.alert('提示', json.message,img1);
				                    } else {
				                        Ext.Msg.alert('提示', '发送成功!',img1);
				                    }  							      
                            },
						    failure: function(response, action) {
				                    text = action.response.responseText;
                                    json = Ext.decode(text);
									Ext.Msg.alert(text);
				                    if(json.success == false){  
                                        Ext.Msg.alert('提示', json.message,img1);
				                    } else {
				                        Ext.Msg.alert('提示', '读取失败',img1);
				                    }        
				                                                
				              }
                        });
                    }
                }
            }
        ]
    });


    
    // --------------- viewport --------------------

    var viewport = new Ext.Viewport({
        layout: 'fit',
        border: false,    
        items: [
                    detailForm
                ]
    });

  

    detailForm.getForm().load({
         url: '<c:url value="/sms/getUserName.do"/>',
         waitMsg: 'loading...',
         success: function(aResponse, aOptions){
         },
         failure: function() {
             Ext.Msg.alert('提示', '请先登录！');                             
         }
     });
 
});
</script>
<%@ include file="/WEB-INF/views/common/footer.jsp"%>
